//
//  EnterCollectionViewCell.m
//  New
//
//  Created by 我爱的妞 on 15/11/5.
//  Copyright © 2015年 @@叶一闽. All rights reserved.
//

#import "EnterCollectionViewCell.h"
#import "UIImageView+WebCache.h"
#import "XJCVideoModel.h"

@implementation EnterCollectionViewCell 

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
      
        self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 315 * SCALEH)];

        self.scrollView.delegate = self;
        
        [self.contentView addSubview:_scrollView];
        
        self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(-25 * SCALEW, 0, 425 * SCALEW, 315 * SCALEH)];
        self.imageView.backgroundColor = [UIColor grayColor];

        [_scrollView addSubview:self.imageView];
    }
    
    [UIView animateKeyframesWithDuration:12.f delay:1 options:UIViewKeyframeAnimationOptionRepeat animations:^{
        

                 

        [UIView addKeyframeWithRelativeStartTime:0 / 12.f relativeDuration:5 / 12.f animations:^{
            
            self.imageView.frame = CGRectMake(- 60 * SCALEW, -35 * SCALEH, 495 * SCALEW, 385 * SCALEH);
            
        }];
        
        [UIView addKeyframeWithRelativeStartTime:5 / 12.f relativeDuration:7 / 12.f animations:^{
            
            self.imageView.frame = CGRectMake(-25 * SCALEW, 0, 425 * SCALEW, 315 * SCALEH);
            
        }];
        
    } completion:nil];
    
    return self;
}

- (void)setModel:(XJCVideoModel *)model{
    
    _model = model;
    
    NSString *url = model.coverForDetail;
    [_imageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil];
    
}

@end
